<!-- -->
<template>
  <div class="login">
    <div class="head">
      <div class="head-title">
        <van-icon name="arrow-left" class="head-back" @click="onClickLeft" />
        <div class="head-number">{{ $t("login.register") }}</div>
      </div>

      <img src="@/assets/images/login/logo.png" alt="" class="head-logo" />
      <div>Palmfun</div>
    </div>
    <div class="bodyCard">
      <div class="text">{{ t("login.emailprogress") }}</div>
      <div class="progress">
        <div class="progress-mock progress-flexmore">
          <div class="progress-circle progress-success-circle">1</div>
          <div
            class="progress-line progress-success-line"
            :class="
              status > 1 ? 'progress-success-line' : 'progress-unsuccess-line'
            "
          ></div>
        </div>
        <div class="progress-mock progress-flexmore">
          <div
            class="progress-circle"
            :class="
              status > 1
                ? 'progress-success-circle'
                : 'progress-unsuccess-circle'
            "
          >
            2
          </div>
          <div
            class="progress-line"
            :class="
              status > 2 ? 'progress-success-line' : 'progress-unsuccess-line'
            "
          ></div>
        </div>
        <div class="progress-mock">
          <div
            class="progress-circle"
            :class="
              status > 2
                ? 'progress-success-circle'
                : 'progress-unsuccess-circle'
            "
          >
            3
          </div>
        </div>
      </div>
      <first v-show="status == 1" @onSubmit="onSubmit" />
      <second v-if="status == 2" @onSubmit="onSubmit" :email="email" />
      <third v-if="status == 3" @onSubmit="onSubmit" :email="email"/>
      <!-- <div class='submit'>
    <van-button round block type="primary" native-type="submit" @click="onNext">
      下一步
    </van-button>
  </div> -->
    </div>
  </div>
</template>
<script setup>
import { ref, reactive } from "@vue/reactivity";
import { useRouter, useRoute } from "vue-router";
import first from "./first.vue";
import second from "./second.vue";
import third from "./third.vue";
import { register, sendEmailCode } from "@/api/user";
import { useI18n } from "vue-i18n";
const router = useRouter();
const { t } = useI18n();
const status = ref(1);
const email = ref(null);

function onSubmit(val) {
  console.log(6666, val,email.value);
  switch (val.type) {
    case 1:
      status.value = 2;
      email.value = val.email;
      break;
    case 2:
      if (val.isAdd) {
        status.value = 3;
      } else {
        status.value = 1;
      }
      break;
    case 3:
      router.push({path:"/login"});
      break;
  }
}
function onClickLeft() {
  history.back();
}
</script>
<style scoped lang="less">
.login {
  height: 100%;
  .head {
    position: relative;
    width: 100%;
    height: 200px;
    text-align: center;
    background: url("@/assets/images/login/bg.png");
    font-size: 16px;
    color: #ffffff;
    line-height: 16px;
    &-title {
      padding-top: 12px;
    }
    &-number {
      font-weight: bold;
    }
    &-back {
      float: left;
      margin-left: 16px;
    }
    &-logo {
      height: 53px;
      position: relative;
      z-index: 999;
      display: block;
      margin: 40px auto 10px;
    }
  }
  .bodyCard {
    position: relative;
    top: -8px;
    background: #ffffff;
    box-shadow: -1px -4px 4px -1px rgba(0, 0, 0, 0.15);
    border-radius: 15px 15px 0px 0px;
    padding: 20px 21px;
    .van-cell.van-cell--borderless.van-field {
      padding-right: 0px;
    }
    .progress {
      /*进度条 */
      display: flex;
      width: 100%;
      &-mock {
        display: flex;
      }
      &-flexmore {
        flex: 1;
      }
      &-circle {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        text-align: center;
        line-height: 28px;
        font-size: 18px;
        display: inline-block;
      }
      &-success-circle {
        border: 2px solid var(--van-primary-color);
        color: var(--van-primary-color);
      }
      &-success-line {
        border-bottom: var(--van-primary-color) 2px dashed;
      }
      &-unsuccess-circle {
        border: 2px solid var(--unprimary-text-color) !important;
        color: var(--unprimary-text-color) !important;
      }
      &-unsuccess-line {
        border-bottom: var(--unprimary-text-color) 2px dashed !important;
      }
      &-line {
        margin-right: 6px;
        margin-left: 6px;
        display: inline-block;
        width: 100%;

        flex: 1;
        position: relative;
        top: -14px;
      }
    }
    .text {
      color: var(--van-nav-bar-icon-color);
      font-size: 21px;
      font-weight: bold;
      line-height: 21px;
      margin-bottom: 24px;
    }

    .submit {
      margin: 20px 55px;
      text-align: center;
      &-text {
        color: var(--van-primary-color);
        text-decoration: underline;
        margin-top: 17px;
        cursor: pointer;
      }
    }
  }
}
</style>
